﻿using System;
using System.Reflection;
using System.Windows.Forms;
using ECP.Service.Utilities;
using ECP.Utilities;

namespace ECP.Client
{
    internal static class Program
    {
        private static void DevExpressMain()
        {
            DevExpress.UserSkins.OfficeSkins.Register();
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.Skins.SkinManager.EnableFormSkinsIfNotVista();
            DevExpress.Skins.SkinManager.EnableMdiFormSkins();
        }

        //    public static UIMessage.FrmMessage FrmMessage;

        public static void InitService(BaseUserInfo userInfo)
        {
            ClientCache.Instance.DTOrganize = null;
            BaseSystemInfo.Version = ConfigHelper.GetValue("Version");
            ServiceManager.Instance.OrganizeService.Load();
            ClientCache.Instance.GetOrganizeList(userInfo);
            ServiceManager.Instance.SequenceService.Load();
            ServiceManager.Instance.StaffService.Load();
            ServiceManager.Instance.RoleService.Load();
            ServiceManager.Instance.ItemDetailsService.Load();
            ServiceManager.Instance.OrganizeService.Load();

            // FrmMessage = new FrameworkUI.UIMessage.FrmMessage();
        }

        [STAThread]
        private static void Main()
        {
            DevExpressMain();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            BaseSystemInfo.CheckOnLine = false;
            BaseSystemInfo.RecordLog = true;
            BaseSystemInfo.IPAddress = BaseSystemInfo.GetIPAddress();
            BaseSystemInfo.MACAddress = BaseSystemInfo.GetMacAddress();
            BaseSystemInfo.StartupPath = Application.StartupPath;
            BaseSystemInfo.AppIco = Application.StartupPath + "/Resource/App.ico";
            BaseSystemInfo.FormIco = Application.StartupPath + "/Resource/Form.ico";
            BaseSystemInfo.ClientCache = true;
            BaseSystemInfo.GetChildrensByCode = true;
            BaseSystemInfo.MainAssembly = Assembly.GetEntryAssembly().GetName().Name;
            ConfigHelper.GetConfig(BaseConfiguration.Instance);
            ResourceManagerWrapper.Instance.LoadResources(Application.StartupPath + @"\Resource\Localization\");
            AppMessage.GetLanguageResource();
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(BaseConfiguration.Instance.CurrentLanguage);

            Application.Run(BaseInterfaceLogic.GetForm(BaseConfiguration.Instance.LoginAssembly, BaseConfiguration.Instance.LoginForm));
        }
    }
}